
package templateswing;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ChecksPanel extends JPanel {
    public ChecksPanel() {
        setBorder(BorderFactory.createTitledBorder("Various CheckBoxes"));
        ActionListener listener=new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                if(blue.isSelected())
                    setBackground(Color.BLUE);
                else if(yellow.isSelected())
                    setBackground(Color.YELLOW);
               else
                   setBackground(null);
            }
        };
        blue.addActionListener(listener);
        add(blue);
        yellow.addActionListener(listener);
        add(yellow);
    }
    
    static JCheckBox blue=new JCheckBox("Blue", false);
    static JCheckBox yellow=new JCheckBox("Yellow", false);
}


